#!/usr/bin/env python 

import inkex
import simplestyle, sys
import andengineutils

class AndEngine(inkex.Effect):
    def __init__(self):
        """
        Constructor.
        Defines the "--what" option of a script.
        """
        # Call the base class constructor.
        inkex.Effect.__init__(self)
        
        # Define string option "--what" with "-w" shortcut and default value "World".
        self.OptionParser.add_option("--hasshape", action="store", type="inkbool", dest="hasshape", default=False, help="has shape")
        self.OptionParser.add_option("--spritesrc", action="store", type="string", dest="spritesrc", default="", help="sprite src")
        self.OptionParser.add_option("--spritetype", action="store", type="int", dest="spritetype", default=0, help="sprite type")
        self.OptionParser.add_option("--spritetextureoption", action="store", type="int", dest="spritetextureoption", default=0, help="sprite texture option")
        
        
    def effect(self):
        for id, node in self.selected.iteritems():
            if (self.options.hasshape):
                andengineutils.creatOrDelete("andengine-hasshape", node, self.options.hasshape, False)
                andengineutils.creatOrDelete("andengine-spritesrc", node, self.options.spritesrc, "")
                andengineutils.creatOrDelete("andengine-spritetype", node, self.options.spritetype, 0)
                andengineutils.creatOrDelete("andengine-spritetextureoption", node, self.options.spritetextureoption, 0)
            else:
                andengineutils.delAttribute("andengine-hasshape", node)
                andengineutils.delAttribute("andengine-spritesrc", node)
                andengineutils.delAttribute("andengine-spritetype", node)
                andengineutils.delAttribute("andengine-spritetextureoption", node)
            
        
if __name__ == '__main__':
    e = AndEngine()
    e.affect()